Skip to content
This repository has been archived by the owner on Sep 1, 2020. It is now read-only.

Latest commit

 

History

History
9 lines (7 loc) · 424 Bytes

8.4 - 常见问题.md

File metadata and controls

9 lines (7 loc) · 424 Bytes

常见问题

如何判断连接是否为WebSocket客户端

通过使用$server->connection_info($fd)获取连接信息,返回的数组中有一项为 websocket_status,根据此状态可以判断是否为WebSocket客户端。

  • WEBSOCKET_STATUS_CONNECTION = 1,连接进入等待握手
  • WEBSOCKET_STATUS_HANDSHAKE = 2,正在握手
  • WEBSOCKET_STATUS_FRAME = 3,已握手成功等待浏览器发送数据帧